from django.views.generic import DetailView
from machete.models import Page,Category,Slideshow,Photo,LinkPhotoSlideshow,LinkSlideshowPage

class PageDetailView(DetailView):

    model = Page
    context_object_name = "page"
    template_name='machete/admin/detailpage.html'
    success_url='/admin/admin_listpage'

    def get_context_data(self, **kwargs):
        # Call the base implementation first to get a context
        context = super(PageDetailView, self).get_context_data(**kwargs)
        #context['category'] = Category.objects.get(pk=kwargs['object'].category.pk)
        return context
   
class CategoryDetailView(DetailView):

    model = Category
    context_object_name = "category"
    template_name='machete/admin/detailcategory.html'
    success_url='/admin/admin_listcategory'

    def get_context_data(self, **kwargs):
        context = super(CategoryDetailView, self).get_context_data(**kwargs)
        # Add in a QuerySet of all the pages
        context['page_list'] = Page.objects.filter(category=kwargs['object'])
        return context
    
   
class SlideshowDetailView(DetailView):

    model = Slideshow
    context_object_name = "slideshow"
    template_name='machete/admin/detailslideshow.html'
    success_url='/admin/admin_listslideshow'

    def get_context_data(self, **kwargs):
        context = super(SlideshowDetailView, self).get_context_data(**kwargs)
        return context

class PhotoDetailView(DetailView):

    model = Photo
    context_object_name = "photo"
    template_name='machete/admin/detailphoto.html'
    success_url='/admin/admin_listphoto'

    def get_context_data(self, **kwargs):
        context = super(PhotoDetailView, self).get_context_data(**kwargs)
        return context
    
class LinkSlideshowPageDetailView(DetailView):

    model = LinkSlideshowPage
    context_object_name = "slideshowpage"
    template_name='machete/admin/link/detailslideshowpage.html'
    success_url='/admin/admin_listlink_slideshowpage'

    def get_context_data(self, **kwargs):
        context = super(LinkSlideshowPageDetailView, self).get_context_data(**kwargs)
        return context

class LinkPhotoSlideshowDetailView(DetailView):

    model = LinkPhotoSlideshow
    context_object_name = "photoslideshow"
    template_name='machete/admin/link/detailphotoslideshow.html'
    success_url='/admin/admin_listlink_photoslideshow'

    def get_context_data(self, **kwargs):
        context = super(LinkPhotoSlideshowDetailView, self).get_context_data(**kwargs)
        return context